<template>
  <div class="layout-all">
    <control :config="config" />
    <div class="layout-header" style="float: left;">
    </div>
    <div class="layout-content">
      <el-table
        :data="tableData"
        stripe
        align="center"
        highlight-current-row
        style="width: 100%; margin-top: 50px;"
      >
        <el-table-column align="center" prop="id" label="序号" width="80"/>
        <el-table-column align="center" prop="remark" label="记录" />
          <el-table-column align="center" prop="level_id" label="更改前等级">
            <template slot-scope="scope">
              <span>{{ level_data[scope.row.level_id - 1] }}</span>
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            prop="new_level_id"
            label="更改后等级"
          >
            <template slot-scope="scope">
              <span>{{ level_data[scope.row.new_level_id - 1] }}</span>
            </template>
          </el-table-column>
          <el-table-column align="center" prop="create_time" label="日期" />
        </el-table>
    </div>
    <el-pagination
      :current-page="current_page"
      :page-size="per_page"
      layout="total, prev, pager, next, jumper"
      :total="total"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
    />
  </div>
</template>

<script>
import control from "@/components/control/control";
export default {
  name:'LevelLog',
  props:['id','type'],
  components: { control },
  data() {
    return {
      config: [
        {
          type: "text",
          placeholder: "请输入内容事项",
          field: "title",
          val: "",
        },
      ],
      value: "",
      searchWhere: {
        title: "",
      },
      tableData: [],
      level_data: [],
      total: 0,
      current_page: 1,
      per_page: 14,
    };
  },
  mounted() {
    this.onSearch();
  },
  methods: {
    // 查询
    handleSizeChange(val) {
      this.onSearch();
    },
    handleCurrentChange(val) {
      this.current_page = val;
      this.onSearch();
    },
    onSearch() {
       const form = {};
      form.page = this.current_page;
      form.map = this.searchWhere;
      form.user_id = this.id;
      form.type = this.type;
      this.get("/admin/user/uplevel_log",form, "POST").then((e) => {
        this.tableData = e.list.data;
        this.level_data = e.level_info;
        this.per_page = e.list.per_page;
        this.total = e.list.total;
        this.current_page = e.list.current_page;
        }
      );
    },
  },
};
</script>

<style>
.layout-all {
  margin-top: 20px;
  margin-left: 10px;
}
.layout-content {
  margin-top: 20px;
}
</style>>
